fix(session): bound retry loop, fix doom-loop guard, treat abort as clean stop#124
Merged
Merged
Conversation
…ort as a clean stop - Cap transient-error retries at MAX_RETRY_ATTEMPTS (10) per message generation. The while(true) retry loop was unbounded, and retry.ts marks any JSON body with an 'error' field as retryable, so a persistently-failing provider (or a permanent error arriving as JSON) retried forever. (#7) - Doom-loop detection now scans the last N *tool* parts (isDoomLoop helper) instead of the last N raw parts. Reasoning models emit a reasoning part before each tool call, so the last 3 raw parts were never 3 identical tool parts and the guard never fired against a genuinely looping tool. (#10) - A user-initiated abort no longer fires the session Error event: it's a clean cancellation, so record it on the message (turn still stops) but don't surface it as an error state in the UI. (#51)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three spend/reliability-safety fixes in the session processor (from the audit):
while(true)retry loop was unbounded, andretry.tsclassifies any JSON body carrying anerrorfield as retryable (Provider Server Error), so a persistently-failing provider — or a permanent error (bad request, context-length) that arrives as JSON — retried forever. Cap atMAX_RETRY_ATTEMPTS = 10per message generation (the counter is per-process, so this is per-message, not per-session), after which the error is terminal.reasoningpart before every tool call, so 3 consecutive tool parts never appeared and the guard never fired against a genuinely looping tool. Now scans the last N tool parts (extractedisDoomLoop, unit-tested).Session.Event.Error: it's a clean cancellation, so it's recorded on the message (the turn still stops) but not rendered as an error state.Tests
test/session/doom-loop.test.tscovers interleaved reasoning/text, differing inputs, below-threshold, a broken streak, and pending calls. Full session suite (83) green.